<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <input type="text" name="请输入手机号" id="phone"/>
<input type="text"> 
<input  type="button" onclick="sendcode()" id="mybutton">

</body>
<script >

        var intervalIndex=10;
        var flag=true;
    function mycode() {
        flag=false;
        intervalIndex=10;
        var myintervalIndex=setInterval(function () {
            intervalIndex--;
        },1000)
        clearInterval(myintervalIndex);
    }
    function sendcode() {
        mycode();
    }
</script>
</html>